package com.ruoyi.project.system.tatic.controller;

import java.util.List;

import com.ruoyi.project.system.tatic.domain.req.FindChannelPromotionRepeatTaticReq;
import com.ruoyi.project.system.tatic.domain.resp.FindChannelPromotionRepeatTaticResp;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.project.system.tatic.domain.TChannelPromotionRepeatTatic;
import com.ruoyi.project.system.tatic.service.ITChannelPromotionRepeatTaticService;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.web.page.TableDataInfo;

/**
 * 渠道推广资源重复率统计Controller
 * 
 * @author ruoyi
 * @date 2024-10-28
 */
@Controller
@RequestMapping("/system/tatic")
public class TChannelPromotionRepeatTaticController extends BaseController
{
    private String prefix = "system/tatic";

    @Autowired
    private ITChannelPromotionRepeatTaticService tChannelPromotionRepeatTaticService;

    @RequiresPermissions("system:tatic:view")
    @GetMapping()
    public String tatic()
    {
        return prefix + "/tatic";
    }

    /**
     * 查询渠道推广资源重复率统计列表
     */
    @RequiresPermissions("system:tatic:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(TChannelPromotionRepeatTatic tChannelPromotionRepeatTatic)
    {
        startPage();
        List<TChannelPromotionRepeatTatic> list = tChannelPromotionRepeatTaticService.selectTChannelPromotionRepeatTaticList(tChannelPromotionRepeatTatic);
        return getDataTable(list);
    }

    /**
     * 导出渠道推广资源重复率统计列表
     */
    @RequiresPermissions("system:tatic:export")
    @Log(title = "渠道推广资源重复率统计", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(TChannelPromotionRepeatTatic tChannelPromotionRepeatTatic)
    {
        List<TChannelPromotionRepeatTatic> list = tChannelPromotionRepeatTaticService.selectTChannelPromotionRepeatTaticList(tChannelPromotionRepeatTatic);
        ExcelUtil<TChannelPromotionRepeatTatic> util = new ExcelUtil<TChannelPromotionRepeatTatic>(TChannelPromotionRepeatTatic.class);
        return util.exportExcel(list, "渠道推广资源重复率统计数据");
    }

    /**
     * 新增渠道推广资源重复率统计
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存渠道推广资源重复率统计
     */
    @RequiresPermissions("system:tatic:add")
    @Log(title = "渠道推广资源重复率统计", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(TChannelPromotionRepeatTatic tChannelPromotionRepeatTatic)
    {
        return toAjax(tChannelPromotionRepeatTaticService.insertTChannelPromotionRepeatTatic(tChannelPromotionRepeatTatic));
    }

    /**
     * 修改渠道推广资源重复率统计
     */
    @RequiresPermissions("system:tatic:edit")
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        TChannelPromotionRepeatTatic tChannelPromotionRepeatTatic = tChannelPromotionRepeatTaticService.selectTChannelPromotionRepeatTaticById(id);
        mmap.put("tChannelPromotionRepeatTatic", tChannelPromotionRepeatTatic);
        return prefix + "/edit";
    }

    /**
     * 修改保存渠道推广资源重复率统计
     */
    @RequiresPermissions("system:tatic:edit")
    @Log(title = "渠道推广资源重复率统计", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(TChannelPromotionRepeatTatic tChannelPromotionRepeatTatic)
    {
        return toAjax(tChannelPromotionRepeatTaticService.updateTChannelPromotionRepeatTatic(tChannelPromotionRepeatTatic));
    }

    /**
     * 删除渠道推广资源重复率统计
     */
    @RequiresPermissions("system:tatic:remove")
    @Log(title = "渠道推广资源重复率统计", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(tChannelPromotionRepeatTaticService.deleteTChannelPromotionRepeatTaticByIds(ids));
    }

    /**
     * 渠道推广资源重复率统计
     */
    @PostMapping( "/findChannelPromotionRepeatTatic")
    @ResponseBody
    public TableDataInfo findChannelPromotionRepeatTatic(FindChannelPromotionRepeatTaticReq req)
    {
        List<FindChannelPromotionRepeatTaticResp> repeatTatic = tChannelPromotionRepeatTaticService.findChannelPromotionRepeatTatic(req);
        return getDataTable(repeatTatic);
    }

    /**
     * 获取所有渠道
     */
    @PostMapping( "/findChannel")
    @ResponseBody
    public AjaxResult findChannel()
    {
        return AjaxResult.success("成功",tChannelPromotionRepeatTaticService.findChannel());
    }
}
